<script>
import { h } from 'vue';

export default {
  data() {
    return {
      tableData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1517 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1519 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }],
      search: ''
    }
  },
  mounted() {

  },
  updated() {
    console.log('updated');
  },
  watch: {
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    formatter(row, column, cellValue, index) {
      console.log('row', row);
      return h('el-input',  {
        value: row.name,
        size: 'mini',
        placeholder: '输入关键字搜索'
      })
    },
  },
}
</script>

<template>
  <section>
    <el-table :data="tableData.filter(data => !search || data.name.toLowerCase().includes(search.toLowerCase()))"
      style="width: 100%">
      <el-table-column label="Date" prop="date">
      </el-table-column>
      <el-table-column label="Name" prop="name" :formatter="formatter">
      </el-table-column>
    </el-table>
  </section>
</template>

<style scoped></style>
